package com.hopes.bizz.poll.town.handler;

import com.hopes.bizz.poll.common.constant.OmConstant;
import com.hopes.bizz.poll.town.service.*;
import lombok.AllArgsConstructor;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * @author lyb
 * @version 1.0
 * @date 2023/10/7 16:33
 */

@Component
@AllArgsConstructor
public class PollTownHisDataFactory {

    private static final Map<Integer, PollTownHisDataService> pollTownMap = new ConcurrentHashMap<>(8);


    private final PollTownRtDataHisService pollTownRtDataHisService;

    private final PollTownMinService pollTownMinService;

    private final PollTownHourService pollTownHourService;

    private final PollTownDayService pollTownDayService;

    private final PollTownMonthService pollTownMonthService;

    private final PollTownYearService pollTownYearService;

    @PostConstruct
    public void init() {
        pollTownMap.put(OmConstant.DATA_TYPE_RT, pollTownRtDataHisService);
        pollTownMap.put(OmConstant.DATA_TYPE_MIN, pollTownMinService);
        pollTownMap.put(OmConstant.DATA_TYPE_HOUR, pollTownHourService);
        pollTownMap.put(OmConstant.DATA_TYPE_DAY, pollTownDayService);
        pollTownMap.put(OmConstant.DATA_TYPE_MONTH, pollTownMonthService);
        pollTownMap.put(OmConstant.DATA_TYPE_YEAR, pollTownYearService);
    }

    public PollTownHisDataService getTownPollService(Integer dataType) {
        return pollTownMap.get(dataType);
    }
}
